<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends CI_Controller {


	public function index()
	{
		if($this->session->userdata('account_id') != null){
			if($this->session->userdata('userlevel') != null){
			
				$data = array(
				'account_id'=>$this->session->userdata('account_id')
				);
				if($this->session->userdata('userlevel') == 1){
					$this->load->view('search_view_admin',$data);
				}else{
					$gid = $this->search_model->getGuardianID($this->session->userdata('account_id'));
					if($this->verifier_model->has_token($gid)){
						if($this->verifier_model->has_students($this->session->userdata('account_id'))){
							$this->load->view('search_view',$data);
						}else{
							redirect(base_url().'addstudent?guardian_id='.$gid[0]['guardian_id']);
						}
					}else{
							redirect(base_url().'tokenrequest?guardian_id='.$gid[0]['guardian_id']);
					}
					
					
				}
			}
			
		}else{
			redirect(base_url().'login');
		}
		
	}

	
}
